<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of imtransform2</title>
  <meta name="keywords" content="imtransform2">
  <meta name="description" content="Applies a general/special homography on an image I">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html images -->
<h1>imtransform2
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Applies a general/special homography on an image I</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function J = imtransform2( I, varargin ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Applies a general/special homography on an image I

 Takes the center of the image as the origin, not the top left corner.
 Also, the coordinate system is row/column format, so H must be also.

 The bounding box of the image is set by the BBOX argument, a string that
 can be 'loose' (default) or 'crop'. When BBOX is 'loose', J includes the
 whole transformed image, which generally is larger than I. When BBOX is
 'crop' J is cropped to include only the central portion of the
 transformed image and is the same size as I. The 'loose' flag is
 currently inexact (because of some padding/cropping). Preserves I's type.

 USAGE
  J=imtransform2(I,H,[method],[bbox],[show],[pad])     % general hom
  J=imtransform2(I,angle,[method],[bbox],[show],[pad]) % rotation
  J=imtransform2(I,dx,dy,[method],[bbox],[show],[pad]) % translation

 INPUTS - common
  I       - 2D image [converted to double]
  method  - ['linear'] 'nearest', 'spline', 'cubic' (for interp2)
  bbox    - ['loose'] or 'crop'
  show    - [0] figure to use for optional display
  pad     - [0] padding value (scalar or 'replicate')

 INPUTS - specific to general homography
  H       - 3x3 nonsingular homography matrix

 INPUTS - specific to rotation
  angle   - angle to rotate in degrees

 INPUTS - specific to translation
  dx      - x translation (right)
  dy      - y translation (up)

 OUTPUTS
  J       - transformed image

 EXAMPLE - general homography (rotation + translation)
  load trees; I=X; method='linear';
  R = rotationMatrix(pi/4); T=[1; 3]; H=[R T; 0 0 1];
  J = imtransform2(I,H,method,'crop',1,'replicate');

 EXAMPLE - general homography (out of plane rotation)
  load trees; I=X; method='nearest';
  R = rotationMatrix([0 1 0],pi/4); z=500;
  H = R; H(1:2,:)=H(1:2,:)*z; H(:,3)=H(:,3)*z;
  J = imtransform2(I,H,method,'loose',1);

 EXAMPLE - rotation
  load trees; I=X; method='bicubic';
  tic; J1 = imrotate(I,55,method,'crop'); toc
  tic; J2 = imtransform2(I,55,method,'crop'); toc
  clf; subplot(2,2,1); im(I); subplot(2,2,2); im(J1-J2);
  subplot(2,2,3); im(J1); subplot(2,2,4); im(J2);

 EXAMPLE - translation
  load trees; I=X; method='bicubic';
  J = imtransform2(X,0,1.5,method,'crop');
  figure(1); clf; im(I,[0 128]); figure(2); clf; im(J,[0 128]);

 See also <a href="textureMap.html" class="code" title="function [IR,boundX,boundY] = textureMap(I, rowDst, colDst, bbox, holeVal)">TEXTUREMAP</a>, INTERP2

 Piotr's Image&amp;Video Toolbox      Version 2.53
 Copyright 2010 Piotr Dollar.  [pdollar-at-caltech.edu]
 Please email me if you find bugs, or have suggestions or questions!
 Licensed under the Lesser GPL [see external/lgpl.txt]</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="im.html" class="code" title="function varargout = im( I, range, extraInf )">im</a>	Function for displaying grayscale images.</li><li><a href="../matlab/rotationMatrix.html" class="code" title="function varargout=rotationMatrix(varargin)">rotationMatrix</a>	Performs different operations dealing with a rotation matrix</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="jitterImage.html" class="code" title="function IJ = jitterImage( I, varargin )">jitterImage</a>	Creates multiple, slightly jittered versions of an image.</li></ul>
<!-- crossreference -->




<!-- Start of Google Analytics Code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4884268-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!-- end of Google Analytics Code -->

<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>
